package com.seckill.config;

import com.seckill.zk.JvmCacheWatcher;
import org.apache.zookeeper.ZooKeeper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author wangzhilong
 * @date 2019-06-19
 */
@Configuration
public class ZKConfig {

    public final static String path = "/seckill" ;


    @Bean
    public ZooKeeper zooKeeper(JvmCacheWatcher watcher) throws IOException {
        ZooKeeper zooKeeper = new ZooKeeper("127.0.0.1:2181", 5000,null);
        zooKeeper.register(watcher);
        watcher.setZooKeeper(zooKeeper);
        return zooKeeper;
    }

}
